package com.beamfield.controller.manage.sys;

import com.beamfield.common.ApiResult;
import com.beamfield.common.PageResult;
import com.beamfield.controller.common.BaseController;
import com.beamfield.service.serviceimpl.manage.sys.PedestalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Zephyr
 * @description:
 * @date 2019/8/6
 */
@RequestMapping("/cms/sys/pedestal")
@Controller
public class PedestalController extends BaseController {

    @Autowired
    private PedestalService pedestalService;

    @RequestMapping("/pedestal_index")
    public ModelAndView index(){
        return new ModelAndView();
    }


    @RequestMapping("/readPedestalData")
    @ResponseBody
    public PageResult readPedestalData(HttpServletRequest request){
        String offset = request.getParameter("offset");
        String limit = request.getParameter("limit");
        String type = request.getParameter("type");
        Long beamId = super.getBeamId(request);
        return pedestalService.readPedestalData(offset, limit, type, beamId);
    }

    @RequestMapping("/delPedestal")
    @ResponseBody
    public ApiResult delPedestal(HttpServletRequest request){
        String id = request.getParameter("id");
        String type = request.getParameter("type");
        return pedestalService.delPedestal(id, type);
    }

    @RequestMapping("/editPedestal")
    @ResponseBody
    public ApiResult editPedestal(HttpServletRequest request){
        String id = request.getParameter("id");
        String type = request.getParameter("type");
        String name = request.getParameter("name");
        String area = request.getParameter("area");
        String location = request.getParameter("location");
        String dado = request.getParameter("dado");
        Long beamId = super.getBeamId(request);
        Long userId = super.getUserId(request);
        return pedestalService.editPedestal(id, type, name, area, location, dado, beamId, userId);
    }
}
